//
//  MTHttpTool.h
//  MeToo
//
//  Created by 俊松何 on 2018/7/3.
//  Copyright © 2018年 tianxie. All rights reserved.
//

#import <Foundation/Foundation.h>



@interface MTBaseData : NSObject

@property (nonatomic, strong) NSString  *message;
@property (nonatomic, assign) NSInteger code;
@property (nonatomic, strong) id  data;

@end

@interface MTError : NSObject
/**
 错误码
 */
@property(nonatomic,assign) NSInteger code;

/**
 错误描述
 */
@property(nonatomic,copy) NSString *errorDescription;

+ (instancetype) netWorkError;

/**
 便利构造器
 
 @param Description   错误描述
 @param Code 错误code
 @return LTError
 */
+ (instancetype) errorWithDescription:(NSString *)Description
                                 code:(NSInteger)Code;

@end

typedef void(^MTSuccess)(MTBaseData *datamodel);
typedef void(^MTFailer)(MTError *error);


static NSString *mtbasePath = @"http://fqliveapi.108usd.com";
//static NSString *mtbasePath = @"http://mitu.108usd.com";

@interface MTHttpTool : NSObject

+(instancetype)shareTool;

-(void)postPath:(NSString *)path
     parameters:(NSDictionary *)parameters
        success:(MTSuccess)success
         failer:(MTFailer)failer;

-(void)getPath:(NSString *)path
    parameters:(NSDictionary *)parameters
       success:(MTSuccess)success
        failer:(MTFailer)failer;


-(void)uploadImageData:(NSData *)data
              progress:(void(^)(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend))uploadProgress
               success:(void(^)(NSString *remotePath,LTFileTokenModel *model))success
                failer:(void(^)(MTError *lterror))failer;

#pragma mark - 上传多张图片方法
-(void)uploadImages:(NSArray *)images
           complete:(void(^)(NSArray<NSDictionary *> *names, MTError *mterror))complete;

-(void)uploadFileData:(NSData *)data
             FileType:(FileType)type
             progress:(void(^)(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend))uploadProgress
              success:(void(^)(NSString *fileUrl,LTFileTokenModel *model))success
               failer:(void(^)(MTError *lterror))failer;

-(NSString *)MD5StringForString:(NSString *)str;




@end
